package com.magic.gre.mvp.presenter;

import com.google.gson.reflect.TypeToken;
import com.magic.gre.entity.BannerBean;
import com.magic.gre.entity.OptionBean;
import com.magic.gre.entity.ThesaurusBean;
import com.magic.gre.entity.base.BaseListModel;
import com.magic.gre.entity.base.BaseObjectModel;
import com.magic.gre.mvp.contract.HomeContract;
import com.magic.gre.mvp.model.HomeModelImpl;
import com.noname.lib_base_java.mvp.BasePresenterImpl;

/**
 * Author: Lmoumou
 * Date: 2019-01-07 15:26
 * 文件名: HomePresenterImpl
 * 描述:
 */
public class HomePresenterImpl extends BasePresenterImpl<HomeContract.View, HomeContract.Model>
        implements HomeContract.Presenter {
    public HomePresenterImpl(HomeContract.View view) {
        super(view);
    }

    @Override
    protected HomeContract.Model creatModel() {
        return new HomeModelImpl();
    }

    @Override
    public void pBannerData() {
        mModel.mBannerData(new CommonObserver<BaseListModel<BannerBean>>(new TypeToken<BaseListModel<BannerBean>>() {
        }.getType()) {
            @Override
            protected void onSuccess(BaseListModel<BannerBean> bannerBeanBaseListModel) {
                mView.vBannerData(bannerBeanBaseListModel.body);
            }

            @Override
            public void onError(int status, String msg) {

            }
        });
    }

    @Override
    public void pOption() {
        mModel.mOption(new CommonObserver<BaseObjectModel<OptionBean>>(new TypeToken<BaseObjectModel<OptionBean>>() {
        }.getType()) {
            @Override
            protected void onSuccess(BaseObjectModel<OptionBean> baseObjectModel) {
                mView.vOption(baseObjectModel.body);
            }

            @Override
            public void onError(int status, String msg) {

            }
        });
    }

    @Override
    public void pThesaurusList() {
        mModel.mThesaurusList(new CommonObserver<BaseListModel<ThesaurusBean>>(new TypeToken<BaseListModel<ThesaurusBean>>() {
        }.getType()) {
            @Override
            protected void onSuccess(BaseListModel<ThesaurusBean> thesaurusBeanBaseListModel) {
                mView.vThesaurusList(thesaurusBeanBaseListModel.body);
            }

            @Override
            public void onError(int status, String msg) {

            }
        });
    }
}
